package com.bocloud.cmp.entity.resource;

import java.util.Date;

import org.springframework.format.annotation.DateTimeFormat;

import com.bocloud.common.utils.DateSerializer;
import com.bocloud.entity.annotations.Column;
import com.bocloud.entity.annotations.IgnoreAll;
import com.bocloud.entity.annotations.PK;
import com.bocloud.entity.annotations.Table;
import com.bocloud.entity.bean.GenericEntity;
import com.bocloud.entity.meta.PKStrategy;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
 * 快照实体类
 * 
 * @author dongkai
 *
 */
@Table("snapshot")
public class Snapshot extends GenericEntity {

	@PK(value = PKStrategy.AUTO)
	private Long id; // ID
	@Column("snapshot_id")
	private String snapshotId; // 快照ID
	@Column("snapshot_val")
	private String snapshotVal; // 快照value
	@Column("volume_id")
	private String volumeId;// 块设备ID
	@Column("size")
	private Integer size; // 大小
	@Column("rollback_status")
	private String rollbackStatus;// 回滚状态
	@Column("vendor_id")
	private Long vendorId; // 云供应商ID
	@IgnoreAll
	private String vendorName; // 云供应商名称
	@Column("region")
	private Long region; // 镜像所在区域
	@IgnoreAll
	private String regionName; // 镜像所在区域名称
	@IgnoreAll
	private String vmName;// 所在虚拟机名称
	@Column("progress")
	private String progress;
	@Column("vm_id")
	private Long vmId;
	@Column("create_time")
	@JsonSerialize(using = DateSerializer.class)
	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createTime; // 快照创建时间

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the snapshotId
	 */
	public String getSnapshotId() {
		return snapshotId;
	}

	/**
	 * @param snapshotId
	 *            the snapshotId to set
	 */
	public void setSnapshotId(String snapshotId) {
		this.snapshotId = snapshotId;
	}

	/**
	 * @return the snapshotVal
	 */
	public String getSnapshotVal() {
		return snapshotVal;
	}

	/**
	 * @param snapshotVal
	 *            the snapshotVal to set
	 */
	public void setSnapshotVal(String snapshotVal) {
		this.snapshotVal = snapshotVal;
	}

	/**
	 * @return the volumeId
	 */
	public String getVolumeId() {
		return volumeId;
	}

	/**
	 * @param volumeId
	 *            the volumeId to set
	 */
	public void setVolumeId(String volumeId) {
		this.volumeId = volumeId;
	}

	/**
	 * @return the size
	 */
	public Integer getSize() {
		return size;
	}

	/**
	 * @param size
	 *            the size to set
	 */
	public void setSize(Integer size) {
		this.size = size;
	}

	/**
	 * @return the rollbackStatus
	 */
	public String getRollbackStatus() {
		return rollbackStatus;
	}

	/**
	 * @param rollbackStatus
	 *            the rollbackStatus to set
	 */
	public void setRollbackStatus(String rollbackStatus) {
		this.rollbackStatus = rollbackStatus;
	}

	/**
	 * @return the vendorId
	 */
	public Long getVendorId() {
		return vendorId;
	}

	/**
	 * @param vendorId
	 *            the vendorId to set
	 */
	public void setVendorId(Long vendorId) {
		this.vendorId = vendorId;
	}

	/**
	 * @return the vendorName
	 */
	public String getVendorName() {
		return vendorName;
	}

	/**
	 * @param vendorName
	 *            the vendorName to set
	 */
	public void setVendorName(String vendorName) {
		this.vendorName = vendorName;
	}

	/**
	 * @return the region
	 */
	public Long getRegion() {
		return region;
	}

	/**
	 * @param region
	 *            the region to set
	 */
	public void setRegion(Long region) {
		this.region = region;
	}

	/**
	 * @return the regionName
	 */
	public String getRegionName() {
		return regionName;
	}

	/**
	 * @param regionName
	 *            the regionName to set
	 */
	public void setRegionName(String regionName) {
		this.regionName = regionName;
	}

	/**
	 * @return the vmName
	 */
	public String getVmName() {
		return vmName;
	}

	/**
	 * @param vmName
	 *            the vmName to set
	 */
	public void setVmName(String vmName) {
		this.vmName = vmName;
	}

	/**
	 * @return the progress
	 */
	public String getProgress() {
		return progress;
	}

	/**
	 * @param progress
	 *            the progress to set
	 */
	public void setProgress(String progress) {
		this.progress = progress;
	}

	/**
	 * @return the vmId
	 */
	public Long getVmId() {
		return vmId;
	}

	/**
	 * @param vmId
	 *            the vmId to set
	 */
	public void setVmId(Long vmId) {
		this.vmId = vmId;
	}

	/**
	 * @return the createTime
	 */
	public Date getCreateTime() {
		return createTime;
	}

	/**
	 * @param createTime
	 *            the createTime to set
	 */
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Snapshot() {
	}

	public Snapshot(String snapshotId, String volumeId, Integer size, Long vendorId, Long region) {
		this.snapshotId = snapshotId;
		this.volumeId = volumeId;
		this.size = size;
		this.vendorId = vendorId;
		this.region = region;
	}

	public void preSave(Long createrId, Long menderId, Long vendorId, Long vmId) {
		this.setCreaterId(createrId);
		this.setMenderId(menderId);
		this.setVendorId(vendorId);
		this.setVmId(vmId);
	}

}
